<?php
/**
 * +----------------------------------------------------------------------
 * | 九月科技-ztuc.cn
 * +----------------------------------------------------------------------
 *                      .::::.
 *                    .::::::::.            | AUTHOR: siyu
 *                    :::::::::::           | EMAIL: ztucke@ztuc.cn
 *                 ..:::::::::::'           | DATETIME: 2020/01/31
 *             '::::::::::::'
 *                .::::::::::
 *           '::::::::::::::..
 *                ..::::::::::::.
 *              ``::::::::::::::::
 *               ::::``:::::::::'        .:::.
 *              ::::'   ':::::'       .::::::::.
 *            .::::'      ::::     .:::::::'::::.
 *           .:::'       :::::  .:::::::::' ':::::.
 *          .::'        :::::.:::::::::'      ':::::.
 *         .::'         ::::::::::::::'         ``::::.
 *     ...:::           ::::::::::::'              ``::.
 *   ```` ':.          ':::::::::'                  ::::..
 *                      '.:::::'                    ':'````..
 * +----------------------------------------------------------------------
 */
declare (strict_types = 1);

namespace app\lnadmin\validate;

use think\Validate;

class Profile extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名'	=>	['规则1','规则2'...]
     *
     * @var array
     */	
	protected $rule = [
        'qq' => 'max:10|number',
        'bio' => 'min:3|max:30',
        'email' => 'require|email|unique:user',
        'mobile' => 'require|mobile|unique:user',
        'password' => [
        'min' => 8, 
        'max' => 32, 
        'regex' => '/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,}$/'
        ],
    ];
    
    /**
     * 定义错误信息
     * 格式：'字段名.规则名'	=>	'错误信息'
     *
     * @var array
     */	
    protected $message = [
        'qq.number' => '请输入正确QQ号',
        'qq.max' => 'QQ输入不正确',
        'bio.min' => '简介不能小于3个字符',
        'bio.max' => '简介不能大于30个字符',
        'email.email' => '电子邮箱格式不正确',
        'email.require' => '电子邮箱不能为空',
        'email.unique' => '邮箱已存在',
        'mobile.mobile' => '手机号格式不正确',
        'mobile.unique' => '手机号已存在',
        'mobile.require' => '手机号不能为空',
        'password.min' => '密码不能小于8个字符',
        'password.max' => '密码不能大于32个字符',
        'password.regex' => '密码必须包含大小写字母/数字/符号任意两者组合',
    ];
}
